#ifndef IDPROVIDER_H
#define IDPROVIDER_H

#include <stdint.h>
#include <iostream>
#include <atomic>


/// \brief Provides IDs.
namespace IdProvider {
// emulating singleton syntax
struct instance
{
  instance() : _id(0) {}
  virtual ~instance() = default;

  std::atomic<uint64_t> _id;
  /// \brief get a unique new ID.
  uint64_t newId(){
    const uint64_t retVal = ++_id;
    return retVal;
  }

  /**
   * \brief Get the last generated ID.
   * \warning Use with caution. This ID is almost surely in use.
   */
  uint64_t currentId() {return _id;}
};

} // namespace IdProvider


#endif /* IDPROVIDER_H */
